using Microsoft.AspNetCore.Mvc;
using Shop.Core.Share;
using Shop.IServices.Admin;
using Shop.Model.Dto.Admin.DrawMoney;
using Shop.Model.View.Admin.DrawMoney;

namespace Shop.AdminApi.Controllers;

/// <summary>
/// 提现服务
/// </summary>
[ApiController]
[Route("admin/[controller]")]
public class DrawMoneyController:ShopControllerBase
{
    private readonly IDrawMoneyService _drawMoneyService;
    private readonly IUserContext _userContext;

    /// <summary>
    /// 
    /// </summary>
    /// <param name="drawMoneyService"></param>
    /// <param name="userContext"></param>
    public DrawMoneyController(IDrawMoneyService drawMoneyService,
        IUserContext userContext)
    {
        _drawMoneyService = drawMoneyService;
        _userContext = userContext;
    }


    /// <summary>
    /// 提现列表
    /// </summary>
    /// <param name="dto"></param>
    /// <returns></returns>
    [HttpGet("DrawMoneyList")]
    public AppResult<PageModel<DrawMoneyListVo>> DrawMoneyList([FromQuery]DrawMoneyListDto dto)
        => _drawMoneyService.DrawMoneyList(dto);
    
    /// <summary>
    /// 提现状态(常量)
    /// </summary>
    /// <returns></returns>
    [HttpGet("DrawMoneyState")]
    public AppResult<List<DrawMoneyStateVo>> DrawMoneyState()
    {
        var drawMoneyStateVo = new List<DrawMoneyStateVo>();
        var drawMoneyStateOne = new DrawMoneyStateVo() { Key = -1, Value = "失败", Sort = 0 };
        var drawMoneyStateTwo = new DrawMoneyStateVo() { Key = 0, Value = "处理中", Sort = 1 };
        var drawMoneyStateThree = new DrawMoneyStateVo() { Key = 1, Value = "打款中", Sort = 2 };
        var drawMoneyStateFour = new DrawMoneyStateVo() { Key = 2, Value = "成功", Sort = 3 };
        drawMoneyStateVo.Add(drawMoneyStateOne);
        drawMoneyStateVo.Add(drawMoneyStateTwo);
        drawMoneyStateVo.Add(drawMoneyStateThree);
        drawMoneyStateVo.Add(drawMoneyStateFour);
        return drawMoneyStateVo;
    }
    
    /// <summary>
    /// 提现类型(常量)
    /// </summary>
    /// <returns></returns>
    [HttpGet("DrawMoneyType")]
    public AppResult<List<DrawMoneyTypeVo>> DrawMoneyType()
    {
        var drawMoneyTypeVo = new List<DrawMoneyTypeVo>();
        var drawMoneyTypeOne = new DrawMoneyTypeVo() { Key = 1, Value = "微信", Sort = 0 };
        var drawMoneyTypeTwo = new DrawMoneyTypeVo() { Key = 2, Value = "银行卡", Sort = 1 };
        drawMoneyTypeVo.Add(drawMoneyTypeOne);
        drawMoneyTypeVo.Add(drawMoneyTypeTwo);
        return drawMoneyTypeVo;
    }


    /// <summary>
    /// 提现审核
    /// </summary>
    /// <returns></returns>
    [HttpPost("DrawMoneyCheck")]
    public async Task<AppResult> DrawMoneyCheck(DrawMoneyCheckDto dto)
        => await _drawMoneyService.DrawMoneyCheck(dto, _userContext.Id);
}